﻿<!DOCTYPE html>
<html>

<head>
<meta charset="UTF-8">
<title>订单结算 - 武汉金刚健身器材商城</title>
<meta name="keywords" content="健身房器材 体育设施 美国Matrix乔山Johnson跑步机 康乐佳健身车 新贵族力量器材 富士按摩椅 红双喜双鱼乒乓球台 星牌双星伯爵台球桌 金陵篮球架 户外路径 pvc运动地胶 硅PU篮球场 EPDM球场跑道 悬浮地板等体育健身设施" />
<meta name="description" content="武汉金刚健身器材商城是华中地区专业的健身体育器材商城，专业批发销售健身房器材 体育设施 美国Matrix乔山Johnson跑步机 康乐佳健身车 新贵族力量器材 富士按摩椅 红双喜双鱼乒乓球台 星牌双星伯爵台球桌 金陵篮球架 户外路径 pvc运动地胶 硅PU篮球场 EPDM球场跑道 悬浮地板等体育健身设施" />
<link rel="stylesheet" href="view/default/css/common.css" />
<link rel="stylesheet" href="view/default/css/animate.min.css" />
<link rel="stylesheet" type="text/css" href="view/default/css/cart.css">		
<link rel="stylesheet" href="view/default/css/quan.css" />
<script src="view/default/js/jquery-1.9.1.min.js" type="text/javascript"></script>
<script src="view/default/js/main.js" type="text/javascript" ></script>
</head>

<body>
<div class="ny-header">
<div class="nb">
<div class="logo">
<a href=""><img src="static/images/logo.gif" alt="" /></a>
</div>
<div class="right cart-center"><a href="login.html" class="red login">马上登录</a>
<a href="reg.html" class="red">免费注册</a><a href="myorder.html">我的订单</a>
<a href="help.html">客户服务</a>
</div>
</div>
</div>
<div class="cart-box">
<div class="nb">
<div class="cart-step">
<ul>
<li class="cart1"><i></i>购物车</li>
<li class="cart2 oncart2"><i></i>确认订单</li>
<li class="cart3"><i></i>付款</li>
<li class="cart4"><i></i>支付成功</li>
</ul>
</div> 
<div class="anonlogin">
<div>
<h3 style="margin-bottom: 10px;text-align: left;color: #007cc3;font-size: 20px;">绑定手机号码
</h3>
</div>
<div class="input-box">
<label class="icon-phone" for="loginmobile"></label>
<input type="text" id="loginmobile" value="" placeholder="手机号码" maxlength="11" autocomplete="off">
</div>
<div class="input-box">
<label class="icon-smscode" for="smscode"></label>
<input type="text" name="smscode" id="smscode" maxlength="8" value="" placeholder="短信验证码" onkeyup="onlyNum(this);" style="width: 52%;">	
<input type="button" class="btn" id="btnSendCode" data-mobileid="loginmobile" data-act ="login" value="获取验证码" />	
</div>

<input type="button" class="btn" id="btnlogin" value="绑定
" />	
<span class="formtip"><i></i><label></label></span>
</div><div class="add-deliver">
<div class="cart-title">
<h3><span>收货人信息</span></h3>						
</div>
<div class="sh-address">
<ul>
<li class="add-add">
<div class="add-box add-box-center" onclick="addAddr();">
<a href="#">
<i class="icon-add-add"></i>
添加新地址
</a>
</div>
</li>
</ul>						
</div>
</div><div class="goods-infor">
<div class="cart-title">
<h3><span>商品信息</span><a href="cart.html" class="vivi-blue">返回购物车修改</a></h3>
</div>
<div class="goods-table">
<div class="goods-thead">
<div class="col col1">
商品
</div>
<div class="col col3">
单价
</div>
<div class="col col4">
数量
</div>
<div class="col col5">
小计
</div>
</div>
<div class="goods-tbody">							
</div>						
</div>
</div>

<div class="style-zhifu">
<div class="cart-title">
<h3><span>支付方式</span></h3>
</div>
<div class="zhifu-box" >
<div class="yue"><span><input type="checkbox" id="userbalance" disabled="disabled">&nbsp;使用余额</span><input type="text" maxlength="9" id="balance" onkeyup="onlyAmount(this,2);" value="" readonly="readonly"><span class="yeuse">（我的余额：<b class="orange-bold"></b>元）</span>。<br /><br /><p>							
<span><input type="checkbox" id="userpoint" disabled="disabled">&nbsp;使用积分</span><input type="text" maxlength="9" id="point" onkeyup="onlyNum(this);" value="" readonly="readonly">
<span class="yeuse">（我的积分：<b class="orange-bold"></b>个）</span>
</p><span id="setpaypwd">为保障您的资金安全，请先<a href="javascript:void(0);" class="vivi-blue"> 设置支付密码</a></span></div>						
</div>
<div class="zhifu-box">
<ul class="zfb" id="paylist"><li>
<i class="icon-check-zf"></i>
<a href="javascript:void(0);" id="alipay"><img src="./upload/img//payment/alipay.png" />支付宝</a>
</li>
<li>
<i class="icon-check-zf"></i>
<a href="javascript:void(0);" id="wxpay_native"><img src="./upload/img//payment/wxpay_native.png" />微信扫码支付</a>
</li>
<li>
<i class="icon-check-zf"></i>
<a href="javascript:void(0);" id="unionpay"><img src="./upload/img//payment/unionpay.png" />银联支付</a>
</li>
		
</ul>
</div>
</div><div class="style-zhifu">
<div class="cart-title">
<h3><span>配送方式</span></h3>
</div>
<div class="zhifu-box">						
<ul class="zfb" id="expresslist"><li><i class="icon-check-zf"></i><a href="javascript:void(0);" id="11">顺丰速递</a></li>
<li><i class="icon-check-zf"></i><a href="javascript:void(0);" id="5">圆通快递</a></li>
<li><i class="icon-check-zf"></i><a href="javascript:void(0);" id="3">中通快递</a></li>
<li><i class="icon-check-zf"></i><a href="javascript:void(0);" id="12">百世汇通</a></li>
<li><i class="icon-check-zf"></i><a href="javascript:void(0);" id="10">如风达快递</a></li>
<li><i class="icon-check-zf"></i><a href="javascript:void(0);" id="9">天天快递</a></li>
<li><i class="icon-check-zf"></i><a href="javascript:void(0);" id="7">EMS邮政</a></li>
<li><i class="icon-check-zf"></i><a href="javascript:void(0);" id="6">韵达快运</a></li>
<li><i class="icon-check-zf"></i><a href="javascript:void(0);" id="4">申通快递</a></li>
</ul>						
</div>
</div><div class="style-zhifu order-invoice">
<div class="cart-title">
<h3><span>发票信息</span></h3>
</div>
<div class="zhifu-box">
<div class="item">
<div class="label">
<ul class="zfb" id="is_invoice">
<li><i class="icon-check-zf"></i><a href="javascript:void(0);" id="1">需要发票</a></li>
<li><i class="icon-check-zf" style="display: block;"></i><a href="javascript:void(0);" id="0" class="selected">不需要发票</a></li>
</ul>
</div>
</div>
<div id="invoiceinfo" style="display: none;">
<div class="item">
<span class="label fl">发票抬头：</span>
<div class="fl">
<ul class="zfb" id="invoice_tite_list">
<li><i class="icon-check-zf" style="display: block"></i><a href="javascript:void(0);" id="1" class="selected">个人</a></li>
<li class="company"><i class="icon-check-zf"></i><a id="2"><input type="text" placeholder="请填写公司发票抬头" maxlength="200"></a></li>
</ul>
</div>
</div>	
<div class="item">
<span class="label fl">发票内容：</span>
<div class="fl">
<ul class="zfb" id="invoice_con"><li><i class="icon-check-zf" ></i><a href="javascript:void(0);" id="明细" >明细</a></li>
<li><i class="icon-check-zf" ></i><a href="javascript:void(0);" id="办公用品" >办公用品</a></li>
<li><i class="icon-check-zf" ></i><a href="javascript:void(0);" id="电脑配件" >电脑配件</a></li>
<li><i class="icon-check-zf" ></i><a href="javascript:void(0);" id="食品" >食品</a></li>
<li><i class="icon-check-zf" ></i><a href="javascript:void(0);" id="生活用品" >生活用品</a></li>
</ul>
</div>
</div>
</div>
</div>
</div><div class="discount">
<div class="h3dy">
<h3 class="yhdyong">使用优惠券<sup id="couponnum">0</sup><i class="icon-arrow"></i><span id="couponselected"style="display: none;"></span></h3> 
</div>
<div class="youhui-box couponlist" id="couponlist">

</div>
</div>
<div class="fare-result">
<div class="cart-title"><h3><span>结算信息</span></h3></div>
<div class="result-box">
<ul>
<li class="first">
<div class="calu-box">
<p class="slivergrey"><span><b class="orange-bold"></b> 件商品 总计：</span><span class="txtmoney">￥<b></b></span></p>
<p class="slivergrey"><span>运费：</span><span class="txtmoney">￥<b id="expfee">0</b></span></p>							
</div>
</li>
<li>
<div style="width: 400px; float: left;font-size: 14px;">
<label class="list-name" for="leavemess">留言：</label>
<textarea style="width: 90%; margin-top:6px;height: 50px;vertical-align: top;" id="leavemess" maxlength="200"></textarea>
</div>
<div class="lside">
<p class="save-passw"><span class="slivergrey">输入支付密码：</span><input type="password" id="cbkpaypwd"></p>
</div>
<div class="rside">
<div class="lside">
<p><span class="slivergrey">应付金额：</span><span class="orange-bold big">￥<b id="payAmount">0.00</b></span></p>
<p class="vivi-blue">提交订单后尽快支付，商品才不会被人抢走哦！</p>
</div>
<a href="javascript:void(0);" class="btn-jiesuan">提交订单</a>
</div>
</li>
</ul>
</div>
</div>			
</div>
</div>

 <div class="footer">
<div class="nb">
<div class="promise"><ul><li><div class="promise-box"><em class="yec-icon-qg yec-icon"></em><div class="word"><h3>正品保障</h3><p>正品行货 放心选购</p></div></div></li><li><div class="promise-box"><em class="yec-icon-fare yec-icon"></em><div class="word"><h3>送货到家</h3><p>免费送货 免费安装</p></div></div></li><li><div class="promise-box"><em class="yec-icon-cs yec-icon"></em><div class="word"><h3>售后无忧</h3><p>7天无理由退货</p></div></div></li><li><div class="promise-box"><em class="yec-icon-help yec-icon"></em><div class="word"><h3>帮助中心</h3><p>您的购物指南</p></div></div></li></ul></div><div class="foot-navson">
<div class="navsonbox"><dl>
<dt><a href="n-DDSXn.html" target="_blank">购物指南</a></dt><dd><a href="n-67Azk.html" target="_blank">找回密码</a></dd>
<dd><a href="n-77Fik.html" target="_blank">搜索商品和店铺</a></dd>
<dd><a href="n-jqfec.html" target="_blank">注册会员</a></dd>
</dl>
<dl>
<dt><a href="n-x4vHY.html" target="_blank">账户和会员</a></dt><dd><a href="n-point.html" target="_blank">积分规则</a></dd>
</dl>
<dl>
<dt><a href="n-jqfBc.html" target="_blank">新手指南</a></dt><dd><a href="n-y4Clq.html" target="_blank">注册登录</a></dd>
<dd><a href="n-NRlFz.html" target="_blank">选购商品</a></dd>
<dd><a href="n-B1Y6p.html" target="_blank">订单支付</a></dd>
<dd><a href="n-16Rqc.html" target="_blank">收货退款</a></dd>
</dl>
<dl>
<dt><a href="n-8DJJy.html" target="_blank">支付方式</a></dt><dd><a href="n-tyM4n.html" target="_blank">货到付款</a></dd>
<dd><a href="n-gjsuL.html" target="_blank">网上支付</a></dd>
<dd><a href="n-16R6c.html" target="_blank">银行转账</a></dd>
</dl>
<dl>
<dt><a href="n-DDSHn.html" target="_blank">配送方式</a></dt><dd><a href="n-9xNEl.html" target="_blank">配送服务查询</a></dd>
<dd><a href="n-OQITC.html" target="_blank">配送费收取标准</a></dd>
</dl>
</div>
<div class="foot-service">
<p>客服电话</p>
<div class="tel">027-85351553<br>13545345059</div>
<p>客服QQ:<a target="_blank" href="http://wpa.qq.com/msgrd?v=3&amp;uin=921701584&amp;site=qq&amp;menu=yes"><img border="0" src="view/default/images/qqkf.gif" alt="金刚在线客服" title="金刚在线客服"></a></p>
</div>
</div>
<div class="foot-sortnav">
<div class="box"><a href="" target="_blank">首页</a></div><div class="box"><a href="n-help.html" >关于我们</a></div>
<div class="box"><a href="n-help.html" >联系我们</a></div>
<div class="box"><a href="timespike.html" >限时抢购</a></div>
<div class="box"><a href="user.html" >会员中心</a></div>
<div class="box"><a href="n-help.html" >帮助中心</a></div>
</div><div class="copyright">
<p>
                    地址：武汉市洪山区武昌珞喻路424号运动频道2楼运动健康精品馆(武汉体育学院旁)
                    <br />
                    电话：027-85351553 13545345059；邮箱：921701584@qq.com
                    <br />
@2007-2019<a href="http://www.jingang2008.com" target="_blank">武汉金刚健身器材商贸有限公司</a>版权所有；ICP备案证书号：鄂ICP备11005836号-1</p>
</div>
</div>
</div>
<p style="display: none;"><script>
var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "https://hm.baidu.com/hm.js?3ec38ca7418002874aaabd14d14ed0cd";
  var s = document.getElementsByTagName("script")[0]; 
  s.parentNode.insertBefore(hm, s);
})();
</script></p><div class="celan-float">
<ul>
<li class="shop"><a href="cart.html" title="购物车"><span class="cartinfo">0</span></a></li>
<li class="ecode">
<a href="#">二维码</a>
<div class="ecode-box radius">
<img src="view/default/images/code.jpg" alt="">
</div>
</li>
<li class="telnum">
<a href="#">电话号码</a>
   <div class="tel-box radius"><span>027-85351553</br>13545345059</span></div>
</li>
<li class="totop"><a href="#">置顶</a></li>
</ul>
</div> 
<div class="edit-address modbox">
<div class="edit-box">
<h3>新增配送信息<i class="close-modbox"></i></h3>
<div class="edit-form">
<ul>
<li>
<label><i>*</i>收货人：</label>
<input type="text" id="sh-name" maxlength="20" class="s-length" />
</li>
<li>
<label><i>*</i>手机号码：</label>
<input type="text" id="sh-phone" maxlength="11" class="s-length">
</li>
<li>
<label>固定电话：</label>
<input type="text" id="sh-tel" maxlength="20" class="s-length">
</li>
<li style="min-height: 25px;">
<label style="width: 75px; float: left;"><i>*</i>所在地区：</label>
<div class="deliver" style="float: left;">								
<div id="store-selector">
<div class="text"><div title="请选择">- 请选择 -</div><b></b><input type="hidden" id="district"></div>                 
<div onclick="$('#store-selector').removeClass('hover')" class="close"></div>
</div>
<div id="store-prompt"><strong></strong></div>
</div>
 
</li>
<li style="clear: both;">
<label><i>*</i>详细地址：</label>
<input type="text" id="sh-address" maxlength="30" class="l-length" />
</li>
</ul>
<div class="setting">
        <input type="checkbox" value="1" id="isdefault">&nbsp;&nbsp;设为默认地址
         </div>
         <input type="hidden" id="id" value="">
         <button class="btn-save" id="saveconsignee" onclick="saveconsignee();">保存</button>
</div>							
</div>
</div>
<div id="edit-paypwd" class="modbox">
<h3>设置支付密码<i class="close-modbox"></i></h3>
<div>
<p><label>手机：</label><input type="text" id="mobile" readonly="readonly" value="" style="width: 93px; border: none;"><input type="button" value="获取验证码" id="sendcode" data-mobileid="mobile" class="btn" onclick="sendSms(this, 'sms_setpaypwd');"></p>
<p><label>手机验证码：</label><input type="text" value="" id="authcode" maxlength="8" class="input" onkeyup="onlyNum(this);"></p>
<p><label>设置支付密码：</label><input type="password" value="" id="paypwd" maxlength="16" class="input"><span class="tip">限数字和字母，6到16个字符</span></p>
<p><label>再输支付密码：</label><input type="password" value="" id="repaypwd" maxlength="16" class="input"></p>
<a href="javascript:void(0);" onclick="editPaypwd();" class="btn" style="margin-left: 94px;margin-top: 20px">提交</a>
</div>
</div>
<div id="mask"></div>
<input type="hidden" id="user_mobile" value="">
<link rel="stylesheet" href="view/default/css/location.css" />

<script src="view/default/js/jquery.SuperSlide.2.1.1.js" type="text/javascript" ></script>
<script src="view/default/js/users.js" type="text/javascript" ></script>
<script src="view/default/js/cart.js" type="text/javascript" ></script>
<script src="view/default/js/location.js" type="text/javascript" ></script>

<script type="text/javascript">
var vir_flag = ;
var goods_amount = 0;
var mostpoint = 50; //最多不超过每笔订单结算金额
var pointpay = 100; //每pointpay个积分可抵1元
var is_invoice=1;
var is_paypwd=false;
$(function(){
loadLayer();
$(".ul-pro-box li").each(function(){
if($(this).index()%3==2){
$(this).css("margin-right","0");
}				
});
$(".slide-like-pro").slide({});		

setTimeout(function() {
get_coupon_list();					
}, 100);
});

$("#loginmobile").change(function() {
var mobile  = $.trim($(this).val());
if (is_mobile(mobile) == false) {
msg("请输入正确手机号码")
return;
}
check_mobile(mobile, callback_check_mobile);
});

function callback_check_mobile(res) {
if ($.trim($("#btnSendCode").data("act")) =='user_bind') {
return false;
}
if(res.err && res.err !='')//已注册
{
$("#btnSendCode").data("act", 'login');	
}
else
{
$("#btnSendCode").data("act", 'reg');
}
}

$("#btnlogin").click(function() {
var mobile = $.trim($("#loginmobile").val()), smscode = $.trim($("#smscode").val()),
act = $.trim($("#btnSendCode").data("act"));

$.post("user_api.html",
{   act: act,
authtype:1,//短信验证
username: (act=='reg' ? '' : mobile),
tel: mobile,
smscode: smscode,
password: '',
repassword: '',
agree: 1,
isOauth: 0,
authcode: '',
autologin:1
},
function(data) {
if (data.err != '') {
msg(data.err);
}
else{
msg("登陆成功");
setTimeout(function() {
window.location.reload();	
},1500)												
}
},"json");

});

//发送验证码
$("#btnSendCode").click(function() {
var act= $.trim($(this).data("act"))
sendSms($(this)[0], 'sms_'+ (act=="user_bind" ?'login':act));		
})

$("#is_invoice a").click(function() {
if ($(this).attr("id") == "1") {
$("#invoiceinfo").slideDown(200);
}
else
{
$("#invoiceinfo").slideUp(100);
}
});
 
//优惠券
$(".h3dy .yhdyong").click(function() {
$(this).find("i.icon-arrow").toggleClass("icon-down");
$(".youhui-box").slideToggle(500);
});
$(".useful li").each(function() {
$(this).click(function() {
$(this).toggleClass("checked").siblings().removeClass("checked");
inputdis();
});
});

//输入余额、积分
$("#balance, #point").blur(function() {		
///inputdis();
//calcTotal();
});

//选中使用余额
$("#userbalance").click(function () {
inputdis();
calcTotal();
$("#balance").css("display", $(this).is(":checked")?"inline-block":"none") ;				
});

//选中使用积分
$("#userpoint").click(function () {
inputdis();
calcTotal();
$("#point").css("display", $(this).is(":checked")?"inline-block":"none") ;						
});

//结算
$(".btn-jiesuan").click(function() {
if($("#btnSendCode").length>0 && $.trim($("#btnSendCode").data("act")) =='user_bind')
{
$("#loginmobile").focus();
msg("请先绑定手机号码");return;
}
if(vir_flag<2) //含实物
{
if ($(".other-add").length==0) {
msg("请先填写您的收货人信息");return;
}
if ($(".default-add").length==0) {
msg("请选择您的收货地址");return;
}
if ($("#expresslist li a.selected").length==0) {
msg("请选择配送方式");return;
}
}
if ($("#payAmount").html() !=0 && $("#paylist li a.selected").length==0) {
msg("请选择支付方式");return;
}				

if (is_paypwd && $.trim($("#cbkpaypwd").val()) == '') {
msg("请填写支付密码");return;
}
//发票信息
var invoice_title ='', invoice_con =''; 
if ($("#is_invoice a.selected").attr("id") ==1) { //开启发票功能
var sl_title = $("#invoice_tite_list a.selected");
invoice_title = sl_title.attr("id") ==1 ? sl_title.html() : $.trim(sl_title.children().val());
invoice_con = $("#invoice_con a.selected").attr("id");
if (invoice_title=='') {
msg("请填写发票抬头");return;
}
if (invoice_con =='') {
msg("请填写发票内容");return;
}
}							

var data ={
act : 'add_order',
cneeid: $(".default-add").attr("id"),
balance:$("#userbalance").is(":checked")? $.trim($("#balance").val()) :0 ,
point : $("#userpoint").is(":checked")? $.trim($("#point").val()) :0 ,
pay : $("#paylist li a.selected").attr("id"),
exp_id : $("#expresslist li a.selected").attr("id"),
paypwd : is_paypwd ? $.trim($("#cbkpaypwd").val()) : '',
invoice_title: invoice_title,
invoice_con : invoice_con,
user_remark : $("#leavemess").val(),
coupon_ids:getCouponIDs()//会员优惠券
};

$(this).attr("disabled", "disabled");
$.getJSON("order.html", data, function(res) {
if( (res.err && res.err != '')) {
msg('操作失败，' + res.err);return;
}
if( (res.url && res.url != '')) {
 window.location.href = res.url;
}

$(this).removeAttr("disabled");
});	
});

//显示支付密码框
function inputdis() {
if( $("#userbalance").is(":checked") || $("#userpoint").is(":checked") || $(".useful li").hasClass("checked")) {
$(".result-box .lside .save-passw").show();
is_paypwd= true;
} else {
$(".result-box .lside .save-passw").hide();
is_paypwd=false;
}
}

var is_count=1,//各状态数量
        	 page = 1; //当前页码
//加载优惠券
 			function get_coupon_list() {		
 				var ids_arr = Array();
 				 $(".goodinfor").each(function() {
 				 	ids_arr.push($(this).attr('id'));
 				 })
 				var goods_ids = ids_arr.toString();
 				 
$.getJSON("myquan.html", {act: "get_coupon", page:page,num:100, goods_ids:goods_ids, is_count:is_count,type:0,is_available:1}, function(res) {
var html ='';
if(res.err) {
msg("加载优惠券失败，".res.err);return;
}
var n =0;
$.each(res.data, function(k, v) {
n++;
html +='<div class="cp-it '+(n%5 ==0 ? 'last' :'')+(v.is_selected==1 ? ' selected' :'')+(v.is_vaild==0 ? ' disabled' :'')+ '" id="'+v.id+'" data-cid="'+v.cid+'" data-amount="'+v.amount+'"><div class="hd">';
html +='<span class="amount">￥<b>'+v.amount+'</b></span>';
html +='<span class="amount_reached">满 '+v.amount_reached+'元 可用</span>';
html +='<span class="date">'+v.date_start+'-'+v.date_end+'</span></div>';
html +='<div class="bt"><div class="option">';
html +='<span><label>限品类</label>：<b class="tit" title="'+v.name+'">'+v.name+'</b></span>';
html +='<span><label>限平台</label>：'+v.client_name+'</span>';
html +='<span><label>限等级</label>：'+v.grade_name+'<i class="tip-down"></i></span>';
html +='<span><label>券编号</label>：'+v.code+'</span></div></div><i class="icon-check-zf"></i></div>';
});

if(is_count ==1)
{
is_count=0;
$("#couponnum").html(res.count[0]);
}
if (res.data.length==0) {
return;
}

$(".couponlist").append(html);						
calcTotal();
sumSelected();
page++; 
});	
}
 			
 			//选择优惠券
 			$(".couponlist").each(function() { 				
$(this).on("click",".cp-it",function() {
var t =$(this);
if(t.hasClass("disabled")) {
return;
}

var cid = t.data("cid");		
if(t.hasClass("selected"))
{
t.removeClass("selected");
}
else
{											
var ids = getSelectedCoupon(); //已选
if(ids !='' && t.hasClass("selected") ==false) {
$.getJSON("myquan.html", {act: "select_coupon", id: cid, ids: ids}, function(res) {
var html ='';
if(res.err) {
msg("选择优惠券失败，".res.err);return;
}
if(res.data && res.data.length > 0) {
$.each(res.data, function(k, v) {
var coupon = $(".couponlist>.selected[data-cid='"+v+"']");
$(".couponlist>.selected[data-cid='"+v+"']").each(function() {
if($(this).attr("id") != t.attr("id")) {
$(this).removeClass("selected");
}
})									
});								
}
sumSelected();
calcTotal();
});	
}

t.addClass("selected");
}

sumSelected();
calcTotal();
});
}); 

function sumSelected(num) {
num = num || $(".couponlist>.selected").length;
$("#couponselected").html("已选<b class='orange-bold'> "+ num + "</b> 张").css("display", (num == 0 ? "none" :"inline-block") );
}

//获取优惠券id
function getSelectedCoupon(){
var ids = '';
$(".couponlist>.selected").each(function() {
ids += $(this).data("cid") + ",";
});
if (ids !='') {
ids = ids.substr(0, ids.length - 1);
}
return ids;
}

//获取会员优惠券id
function getCouponIDs(){
var ids = '';
$(".couponlist>.selected").each(function() {
ids += $(this).attr("id") + ",";
});
if (ids !='') {
ids = ids.substr(0, ids.length - 1);
}
return ids;
}
</script>
</body>

</html>
